#include <string>

#include "doctest.h"
#include "ylt/struct_pack.hpp"
#include "ylt/struct_pack/type_calculate.hpp"
// struct_pack support 255 member max
struct many_members {
  int a1;
  std::string b1;
  int a2;
  std::string b2;
  int a3;
  std::string b3;
  int a4;
  std::string b4;
  int a5;
  std::string b5;
  int a6;
  std::string b6;
  int a7;
  std::string b7;
  int a8;
  std::string b8;
  int a9;
  std::string b9;
  int a10;
  std::string b10;
  int a11;
  std::string b11;
  int a12;
  std::string b12;
  int a13;
  std::string b13;
  int a14;
  std::string b14;
  int a15;
  std::string b15;
  int a16;
  std::string b16;
  int a17;
  std::string b17;
  int a18;
  std::string b18;
  int a19;
  std::string b19;
  int a20;
  std::string b20;
  int a21;
  std::string b21;
  int a22;
  std::string b22;
  int a23;
  std::string b23;
  int a24;
  std::string b24;
  int a25;
  std::string b25;
  int a26;
  std::string b26;
  int a27;
  std::string b27;
  int a28;
  std::string b28;
  int a29;
  std::string b29;
  int a30;
  std::string b30;
  int a31;
  std::string b31;
  int a32;
  std::string b32;
  int a33;
  std::string b33;
  int a34;
  std::string b34;
  int a35;
  std::string b35;
  int a36;
  std::string b36;
  int a37;
  std::string b37;
  int a38;
  std::string b38;
  int a39;
  std::string b39;
  int a40;
  std::string b40;
  int a41;
  std::string b41;
  int a42;
  std::string b42;
  int a43;
  std::string b43;
  int a44;
  std::string b44;
  int a45;
  std::string b45;
  int a46;
  std::string b46;
  int a47;
  std::string b47;
  int a48;
  std::string b48;
  int a49;
  std::string b49;
  int a50;
  std::string b50;
  int a51;
  std::string b51;
  int a52;
  std::string b52;
  int a53;
  std::string b53;
  int a54;
  std::string b54;
  int a55;
  std::string b55;
  int a56;
  std::string b56;
  int a57;
  std::string b57;
  int a58;
  std::string b58;
  int a59;
  std::string b59;
  int a60;
  std::string b60;
  int a61;
  std::string b61;
  int a62;
  std::string b62;
#ifndef _MSC_VER
  // too many variable may cause msvc OOM, disable least variables
  int a63;
  std::string b63;
  int a64;
  std::string b64;
  int a65;
  std::string b65;
  int a66;
  std::string b66;
  int a67;
  std::string b67;
  int a68;
  std::string b68;
  int a69;
  std::string b69;
  int a70;
  std::string b70;
  int a71;
  std::string b71;
  int a72;
  std::string b72;
  int a73;
  std::string b73;
  int a74;
  std::string b74;
  int a75;
  std::string b75;
  int a76;
  std::string b76;
  int a77;
  std::string b77;
  int a78;
  std::string b78;
  int a79;
  std::string b79;
  int a80;
  std::string b80;
  int a81;
  std::string b81;
  int a82;
  std::string b82;
  int a83;
  std::string b83;
  int a84;
  std::string b84;
  int a85;
  std::string b85;
  int a86;
  std::string b86;
  int a87;
  std::string b87;
  int a88;
  std::string b88;
  int a89;
  std::string b89;
  int a90;
  std::string b90;
  int a91;
  std::string b91;
  int a92;
  std::string b92;
  int a93;
  std::string b93;
  int a94;
  std::string b94;
  int a95;
  std::string b95;
  int a96;
  std::string b96;
  int a97;
  std::string b97;
  int a98;
  std::string b98;
  int a99;
  std::string b99;
  int a100;
  std::string b100;
  int a101;
  std::string b101;
  int a102;
  std::string b102;
  int a103;
  std::string b103;
  int a104;
  std::string b104;
  int a105;
  std::string b105;
  int a106;
  std::string b106;
  int a107;
  std::string b107;
  int a108;
  std::string b108;
  int a109;
  std::string b109;
  int a110;
  std::string b110;
  int a111;
  std::string b111;
  int a112;
  std::string b112;
  int a113;
  std::string b113;
  int a114;
  std::string b114;
  int a115;
  std::string b115;
  int a116;
  std::string b116;
  int a117;
  std::string b117;
  int a118;
  std::string b118;
  int a119;
  std::string b119;
  int a120;
  std::string b120;
  int a121;
  std::string b121;
  int a122;
  std::string b122;
  int a123;
  std::string b123;
  int a124;
  std::string b124;
  int a125;
  std::string b125;
  int a126;
  std::string b126;
  int a127;
  std::string b127;
  int a128;
  int a129;
#endif
};
struct many_members2 : public many_members {};
STRUCT_PACK_REFL(many_members2, a1, b1, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6,
                 a7, b7, a8, b8, a9, b9, a10, b10, a11, b11, a12, b12, a13, b13,
                 a14, b14, a15, b15, a16, b16, a17, b17, a18, b18, a19, b19,
                 a20, b20, a21, b21, a22, b22, a23, b23, a24, b24, a25, b25,
                 a26, b26, a27, b27, a28, b28, a29, b29, a30, b30, a31, b31,
                 a32, b32, a33, b33, a34, b34, a35, b35, a36, b36, a37, b37,
                 a38, b38, a39, b39, a40, b40, a41, b41, a42, b42, a43, b43,
                 a44, b44, a45, b45, a46, b46, a47, b47, a48, b48, a49, b49,
                 a50, b50, a51, b51, a52, b52, a53, b53, a54, b54, a55, b55,
                 a56, b56, a57, b57, a58, b58, a59, b59, a60, b60, a61, b61);
TEST_CASE("test many members") {
  int size = 385;

#ifdef _MSC_VER
  size = 188;
#endif
  CHECK(struct_pack::get_type_literal<many_members>().size() == size);
  CHECK(struct_pack::get_type_literal<many_members2>().size() == 185);
}